
import java.util.ArrayList;

/* Piece Objects represent all units that can belong to a Player.
// Pieces can be Checkers, Kings, Mines, Safe Zones, or Blocked Zones. */

class Piece{
	Location location;
	String owner;  //the name of the Player that controls this piece
	boolean isVisible;  //visibility of the Piece during gameplay.  This is set by each type of Piece when created
    boolean jumpable; // set to true if a piece can be jumped over by enemy pieces. BlockedZone will have this set to false.
    boolean passable; // true if a piece can be passed through, such as safe zones and mines.
    boolean explodeOnEnemyContact; // if an enemy hops on this piece, the piece explodes, or vanishes.
    boolean destroyEnemyOnContact; // if an enemy hops on this piece, it gets destroyed.
    int moveRange; // represents how far a piece can move in one direction. -1 for infinite, 0 for stationary
    boolean canWarpAndMove; // allows a piece to warp and/or move in the same turn.
    boolean safeOnContact; // makes other pieces be safe when they rest over this one.
    ArrayList<Location> movePositions; // a list of directions that control how a piece moves
    int direction; //represents the direction of a Piece along the board, -1 is down, 1 is up the board
    boolean hasWarped; //Set to show if a piece has already warped during their turn
	boolean hasJumped; //Set to show if a piece has already jumped during their turn, might be a chain
	int jumpRange; //Allows for jumping multiple pieces at once, if 1 piece can jump one enemy piece at a time
	boolean warp;//Some pieces can warp, ie Kings


	//Class constructor:  Accepts four strings as parameters to initialize variables
	public Piece(String playerName, String x1, String y1, String z1){
		owner = playerName;

		//Create the location object from the supplied strings.  Trim the strings before calling parseInt as
		//parseInt hates trailing/leading 0s
		location = new Location(Integer.parseInt(x1.trim()), Integer.parseInt(y1.trim()), Integer.parseInt(z1.trim()));
		}

	//Returns the x, y, and z locations as a string in format "x,y,z"
	String getLocation(){
		return location.toString();
		}

	//Set the location of a Piece in the format of "x,y,z"
	void setLocation(String loc){
		String[] locData = loc.split(","); //x y and z are separated by ","

		//Trim the strings before calling parseInt as parseInt hates trailing/leading 0s.
		//Once converted to ints, call the move method
		location.move(Integer.parseInt(locData[0].trim()), Integer.parseInt(locData[1].trim()), Integer.parseInt(locData[2].trim()));
		}

	//Return the name of the Player that owns the piece
	String getOwner(){
		return owner;
		}

	//Set the name of the Player that owns the piece
	void setOwner(String playerName){
		owner = playerName;
		}

}